<template>
  <div class="center-warp">
    <div class="center-content-body">
      <div class="content-gear-group" :class="{'rotate-gear-group':rotateGear}">
        <div class="gear-item out-gear"></div>
        <div class="gear-item gear-inner-1"></div>
        <div class="gear-item gear-inner-2"></div>
        <div class="gear-item gear-inner-3"></div>
        <div class="gear-item gear-inner-3-1"></div>
        <div class="gear-item gear-inner-4"></div>
        <div class="gear-item gear-inner-5"></div>
        <div class="gear-item gear-inner-6"></div>
        <div class="gear-item inner-triangle">
          <div class="inner-triangle-item"></div>
          <div class="inner-triangle-item"></div>
          <div class="inner-triangle-item"></div>
          <div class="inner-triangle-item"></div>

          <div class="inner-triangle-cont">
            <span class="comp-num">{{numberValue}}</span>
          </div>
        </div>
      </div>

      <AppRotate :list="list" @handelBall="handelBall" v-show="show"></AppRotate>
    </div>
  </div>
</template>

<script>

import AppRotate from './AppRotate'

export default {
  components: {AppRotate},
  props: {
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      numberValue: '',
      show: false,
      rotateGear: false
    };
  },
  computed: {
    camListNum() {
      return this.list.length || 0
    },
  },
  mounted() {
    this.$nextTick(() => {
      setTimeout(() => {
        this.rotateGear = true
      }, 100)
      setTimeout(() => {
        this.show = true
        if (this.list.length) {
          this.numberValue = this.list[0].pluginsNum
        }
      }, 2100)
    });
  },
  methods: {
    handelBall(id, index, item) {
      this.numberValue = item.pluginsNum;
      this.$emit("handelBall", id);
    },
  },
};
</script>

<style lang="scss" scoped>
  $error: red;
  $blue: blue;
  $orange: #f7903d;
  $success: #2aef8a;
  $gray: gray;

  .center-warp {
    height: 100%;
    width: 100%;
    transform-style: preserve-3d;
    perspective: 8000px;
  }

  .center-content-body {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /*transform-style: preserve-3d;*/
    perspective: 8000px;
    position: relative;

    .content-gear-group {
      width: 400px;
      height: 400px;
      border-radius: 50%;
      position: relative;
      transform-style: preserve-3d;
      perspective: 8000px;
      transition: all 2.1s;
      display: flex;
      align-items: center;
      justify-content: center;

      &.rotate-gear-group {
        transform: rotateX(60deg);
      }

      .gear-item {
        position: absolute;
        margin: auto;
        width: 100%;
        height: 100%;
        transform-style: preserve-3d;
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center center;
      }

      .out-gear {
        background-image: url("~@/assets/img/center/gear.png");
        animation: along_rotate 9s linear 2s infinite;
      }

      .gear-inner-1 {
        width: 93%;
        height: 93%;
        background-image: url("~@/assets/img/center/gear-inner-1.png");
        animation: back_rotate 5s linear 2s infinite;
      }

      .gear-inner-2 {
        width: 90%;
        height: 90%;
        background-image: url("~@/assets/img/center/gear-inner-2.png");
        transform: translateZ(10px);
      }

      .gear-inner-3 {
        width: 75%;
        height: 75%;
        background-image: url("~@/assets/img/center/gear-inner-3.png");
        transform: translateZ(25px);
      }

      .gear-inner-3-1 {
        width: 75%;
        height: 75%;
        background-image: url("~@/assets/img/center/gear-inner-3-1.png");
        transform: translateZ(25px);
        animation: along_rotate3-1 4s linear 2s infinite;
      }

      .gear-inner-4 {
        /*border: 2px solid #409eff;*/
        /*border-radius: 50%;*/

        width: 60%;
        height: 60%;
        background-image: url("~@/assets/img/center/gear-inner-4.png");
        transform: translateZ(30px);
      }

      /*白色半圆*/
      .gear-inner-5 {
        width: 55%;
        height: 55%;
        /*border: 1px solid #fff;*/
        /*border-radius: 50%;*/
        /*border-bottom-color: transparent;*/
        /*border-top-color: transparent;*/

        background-image: url("~@/assets/img/center/gear-inner-5.png");
        transform: translateZ(30px);
        animation: dom_rotate1 4s linear 2s infinite;
      }

      .gear-inner-6 {
        width: 45%;
        height: 45%;
        background-image: url("~@/assets/img/center/gear-inner-6.png");
        transform: translateZ(30px);
        animation: along_rotate6 10s linear 2s infinite;
      }

      .inner-triangle {
        width: 40%;
        height: 40%;
        position: absolute;
        transform: translateZ(30px) rotate(45deg);
        display: flex;
        align-items: center;
        justify-content: center;


        .inner-triangle-item {
          position: absolute;
          width: 15px;
          height: 15px;
          /*background-color: rgba(255, 255, 255, 0.3);*/
          background-image: url("~@/assets/img/center/inner-triangle.png");
          background-repeat: no-repeat;
          background-size: 100% 100%;
          background-position: center center;

          &:nth-child(1) {
            top: 0;
            left: 0;
            right: 0;
            margin: 0 auto;
            transform: rotate(180deg) translateY(0);
            animation: triangle-1 2s linear 2s infinite;
          }

          &:nth-child(2) {
            top: 0;
            right: 0;
            bottom: 0;
            margin: auto 0;
            transform: rotate(-90deg) translateY(0);
            animation: triangle-2 2s linear 2s infinite;
          }

          &:nth-child(3) {
            bottom: 0;
            left: 0;
            right: 0;
            margin: 0 auto;
            transform: rotate(0) translateY(0);
            animation: triangle-3 2s linear 2s infinite;
          }

          &:nth-child(4) {
            top: 0;
            left: 0;
            bottom: 0;
            margin: auto 0;
            transform: rotate(90deg) translateY(0);
            animation: triangle-4 2s linear 2s infinite;
          }
        }

        .inner-triangle-cont {
          position: absolute;
          margin: auto 0;
          transform: rotateX(-90deg) rotateY(45deg) translateY(-30px);
          color: #ffffff;
          font-size: 45px;
          text-shadow: 0 0 2px 2px #666;
        }
      }
    }
  }

  /*顺时针*/
  @keyframes along_rotate {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }

  /*逆时针*/
  @keyframes back_rotate {
    0% {
      transform: rotate(360deg);
    }

    100% {
      transform: rotate(0deg);
    }
  }

  @keyframes along_rotate3-1 {
    0% {
      transform: rotate(0deg) translateZ(25px);
    }

    100% {
      transform: rotate(360deg) translateZ(25px);
    }
  }


  @keyframes dom_rotate1 {
    0% {
      transform: rotate(0deg) translateZ(30px);
    }
    50% {
      transform: rotate(-45deg) translateZ(30px);
    }
    100% {
      transform: rotate(0deg) translateZ(30px);
    }
  }

  @keyframes along_rotate6 {
    0% {
      transform: rotate(0deg) translateZ(30px);
    }
    50% {
      transform: rotate(180deg) translateZ(30px);
    }
    100% {
      transform: rotate(360deg) translateZ(30px);
    }
  }


  @keyframes dom_rotate3 {
    0% {
      transform: rotate(0deg);
    }
    25% {
      transform: rotate(90deg);
    }
    50% {
      transform: rotate(180deg);
    }
    75% {
      transform: rotate(240deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }

  @keyframes run {
    from {
      transform: rotateZ(0);
    }

    to {
      transform: rotateZ(360deg);
    }
  }

  @keyframes triangle-1 {
    0% {
      transform: rotate(180deg) translateY(0);
    }

    50% {
      transform: rotate(180deg) translateY(-20px);
    }

    100% {
      transform: rotate(180deg) translateY(0);
    }
  }

  @keyframes triangle-2 {
    0% {
      transform: rotate(-90deg) translateY(0);
    }

    50% {
      transform: rotate(-90deg) translateY(-20px);
    }

    100% {
      transform: rotate(-90deg) translateY(0);
    }
  }

  @keyframes triangle-3 {
    0% {
      transform: rotate(0) translateY(0);
    }

    50% {
      transform: rotate(0) translateY(-20px);
    }

    100% {
      transform: rotate(0) translateY(0);
    }
  }

  @keyframes triangle-4 {
    0% {
      transform: rotate(90deg) translateY(0);
    }

    50% {
      transform: rotate(90deg) translateY(-20px);
    }

    100% {
      transform: rotate(90deg) translateY(0);
    }
  }
</style>
